#ifndef QFIGURE_H
#define QFIGURE_H

#include <QLabel>
#include <QMouseEvent>
#include <QDebug>
#include <Qt>
#include <qpainter.h>

struct bBox
{
	QRect box;
	int idx;
};

class QFigure : public QLabel
{
	Q_OBJECT
public:
	enum BrushType{none,pRect,mRect,pEllipse,mEllipse,pPloy,mPloy};

	explicit QFigure(QWidget *parent = 0);

	void setPixmap(const QPixmap &);

	void SetROI(QList<bBox>&);

	void mousePressEvent(QMouseEvent *);

	void mouseMoveEvent(QMouseEvent *);
	
	void mouseReleaseEvent(QMouseEvent *);

	void update(QPoint p);

	void draw(QPoint p);

	void draw();
	
	void setBox(QPoint p1, QPoint p2);

	void choseBox(int num);

	void setBrushType(BrushType bt) { BT = bt;
	if (bt == pPloy) { drawPloy(true); }
	if (bt == mPloy) { drawPloy(false); }
	}

	void drawPloy(bool plus);
	
	void clear();

	void saveRoi(QString add) { roi.save(add); }


private:
	bool PorM;

	BrushType BT;

	int boxnum;

	bool Update;

	QVector<QPointF> ploypoints;

	QList<bBox> *roiaddress;

	QPoint oldp;

	bool _mouseMove;

	QImage originalImg;

	QImage curImg;

	QImage roi;
signals:

	public slots:

};

#endif // QFIGURE_H